home *** CD-ROM | disk | FTP | other *** search
- *****Listing 2*****
-
- typedef int truth;
- const truth forever = 1;
- class Editor {
- public:
- Editor( char *fname) : b( fname),
- input(fname), output( "", "w")
- {
- filename = new char[strlen( fname) + 1];
- strcpy( filename, fname);
-
- rp = ®
- }
-
- void eval()
- {
- while( forever)
- (this->*action[input.get()])();
- }
-
- void go() { rp->go( b, output); }
-
- void print() { rp->print( b, output); }
-
- void insert() { rp->insert( b, input); }
-
- void del() { rp->del( b, kbuf, output); }
-
- void put() { rp->put( b, kbuf); }
-
- void quit() { exit(0); }
-
- void eerror() { output.put( "?\n"); } // error function
-
- void donothing() {}
- private:
- Buffer b;
- File input;
- File output;
-
- Register Editor::*rp;
- Register reg;
- Iregister ireg;
- Buffer kbuf; // kill buffer
- };
-
-